<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<!--Converted with LaTeX2HTML 96.1 (Feb 5, 1996) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds -->


<title>Strategic Defense Initiative</title>
<meta name="description" content="Strategic Defense Initiative">
<meta name="keywords" content="htmlatex">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<link rel="STYLESHEET" href="acm-00497_archivos/htmlatex.css">
</head><body bgcolor="#ffffff" lang="EN">
 <center><table bgcolor="#0060f0"><tbody><tr><td><b><font color="#c0ffff" size="5">&nbsp;<a name="SECTION0001000000000000000000">Strategic Defense Initiative</a></font>&nbsp;</b></td></tr></tbody></table></center>
<p>
``Commander! Commander! Please wake up commander!''
</p><p>
``... mmmph. What time is it?''
</p><p>
``4:07 am, Commander. The following message just arrived on the emergency zeta priority classified
scrambler, marked your eyes only.''
</p><p>
You grudgingly take the letter, rub the sleep from your eyes,
fleetingly wish that the 'Backer closed at an earlier hour, and start
to read.
</p><p>
</p><pre>``Dear StarWars SDI Commander,

    Bad news, buddy. Crazy Boris had a bit too much vodka last night
    and when he woke up this morning, instead of the snooze button
    on his alarm clock, he ... well, let me put it this way: we've got
    tons of nuclear missles flying this way. Unfortunately, all that
    we have is a chart of the altitudes at which the missles are
    flying, arranged by the order of arrivals. Go for it, buddy.
    Good luck.

                                           Secretary of Defense

    P.S. Hilly and Bill say hi.''</pre>
<p>
To make things worse, you remeber that SDI has a fatal flaw due to the budget cuts. When SDI sends
out missles to intercept the targets, every missle has to fly higher than the previous one. In other
words, once you hit a target, the next target can only be among the ones that are flying at higher altitudes than
the one you just hit.
</p><p>
For example, if the missles are flying toward you at heights of 1, 6, 2, 3, and 5 (arriving in that order),
you can try to intercept the first two, but then you won't be able to get the ones flying at 2, 3, 5 because they
are lower than 6. Your job is to hit as many targets as possible. So you have to quickly write a program to
find the best sequence of targets that the flawed SDI program is going to destroy.
</p><p>
Russian war tactics are fairly strange; their generals are stickers for mathematical precision. Their missles
will always be fired in a sequence such that there will only be <em>one</em> solution to the problem posed above.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001001000000000000000">Input and Output</a></font></h2>
<p>
The input begins with a single positive integer on a line by itself indicating
the number of the cases following, each of them as described below. This line is
followed by a blank line, and there is also a blank line between two consecutive
inputs.
</p><p>
each input to your program will consist of a sequence of integer altitudes, each on a separate line.
</p><p>
For each test case, the output must follow the description below. The outputs of
two consecutive cases will be separated by a blank line.
</p><p>
Output from your program should contain the total number of targets you can hit, followed by the altitudes
of those targets, one per line, in the order of their arrivals.
</p><p>
</p><h2><font color="#0070e8"><a name="SECTION0001002000000000000000">Sample Input</a></font></h2>
<p>
</p><pre>1

1
6
2
3
5</pre>
<h2><font color="#0070e8"><a name="SECTION0001003000000000000000">Sample Output</a></font></h2>
<p>
</p><pre>Max hits: 4
1
2
3
5</pre>
</body></html>